<?php

namespace Frieza\Modules\Position\Controllers;

use Doraemon\model\Position\PositionExtend;
use Doraemon\service\position\AdmOperationModule;
use Doraemon\tools\ImgUrl;
use Encore\Admin\Grid;
use Encore\Admin\Widgets\Form;
use Illuminate\Http\Request;


class Tab4OperationPosController extends BaseController
{
    use BaseTrait;

    public function extendList(Grid $grid)
    {
        $grid->column('pos', '位置');
        $grid->column('ext->title', '标题');
        $grid->column('ext->key_word', '副标题');
        $grid->column('pic_url', '图片')->image();
    }


    public function saveModule(Request $request, $baseInfoId)
    {
        $data = $request->all();
        $title = $request->input('title', '');
        $keyWord = $request->input('key_word', '');
        PositionExtend::saveOperationPos($baseInfoId, $title, $keyWord);
    }

    public function beforeTitleForm(Form $form)
    {
        $seed = range(1, 20);
        $form->select('base.pos', '位置')->options(array_combine($seed, $seed));
        $form->text('title', '标题');
        $form->text('key_word', '副标题');
        $form->imgUpload('base.pic_id', '图片', false, ['imgType' => ImgUrl::APPTYPE_OP, 'imgSize' => ImgUrl::IMAGE_SIZE_OP_ORI]);
    }

}
